<template>
  <div class="order-item">
    <div class="item-title">
      <div class="title">{{ itemData.unitName }}</div>
      <div class="orderStatusDess">{{ itemData.orderStatusDesc }}</div>
    </div>
    <div class="item-info">
      <img :src="itemData.unitPicture" alt="" />
      <div class="item-cover">
        <div class="left">
          <div class="start">
            <div class="md">
              {{ getData(itemData.checkInDate) }}
            </div>
            <div class="weektime">
              {{
                getWeekData(itemData.checkInDate) + itemData.checkInLatestTime
              }}
            </div>
          </div>
          <div class="icon">
            <div>
              <img src="../../../assets/img/icon_right_orderlist.png" alt="" />
            </div>
          </div>
          <div class="end">
            <div class="md">
              {{ getData(itemData.checkOutDate) }}
            </div>
            <div class="weektime">
              {{
                getWeekData(itemData.checkOutDate) + itemData.checkOutLatestTime
              }}
            </div>
          </div>
        </div>
        <div class="right">
          <p class="name">支付总价</p>
          <div style="color: var(--color)">{{ itemData.prepayAmount }}￥</div>
        </div>
      </div>
    </div>
    <div class="item-botton"></div>
  </div>
</template>

<script setup>
import { computed } from "vue";
defineProps({
  itemData: {
    type: Object,
    default: {},
  },
});
// 计算 XX月 XX日
const getData = (time) => {
  let date = new Date(time);
  return `${date.getMonth() + 1}月${date.getDate()}日`;
};
// 计算星期
const getWeekData = (time) => {
  let date = new Date(time);
  // charAt(date.getDay()) String.charAt() 返回下标字符
  const str = "日一二三四五六".charAt(date.getDay());
  console.log(str);
  return `周${str}`;
};
</script>

<style lang="less" scoped>
.order-item {
  margin-top: 10px;
  background-color: #fff;
  padding: 0px 16px;
  .item-title {
    padding: 20px 0px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    .title {
      max-width: 204px;
      font-size: 12px;
      color: #333;
      line-height: 12px;
      overflow: hidden;
      word-wrap: normal;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
    .orderStatusDess {
      font-size: 18px;
      color: #ff9645;
      letter-spacing: 0;
    }
  }
  .item-info {
    position: relative;
    height: 223px;
    width: 100%;
    border-radius: 6px;
    img {
      width: 100%;
      height: 100%;
      border-radius: 6px;
    }
    .item-cover {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: space-between;
      height: 60px;
      background: rgba(9, 10, 14, 0.7);
      border-radius: 0 0 6px 6px;
      color: #fff;
      padding: 10px 0px;
      .left {
        height: 100%;
        flex: 1;
        display: flex;
        flex-direction: row;
        text-align: center;
        line-height: 1;
        padding: 0 30px;
        .icon {
          width: 16px;
          height: 100%;
          display: flex;
          flex-direction: column;
          justify-content: center;
          margin: 0 10px;
          img {
            width: 16px;
            height: 10px;
          }
        }
        .start,
        .end {
          display: flex;
          flex-direction: column;
          justify-content: center;
        }
      }

      .right {
        height: 100%;
        border-left: 2px solid #fff;
        position: relative;
        width: 105px;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        .name {
          color: #fff;
          text-align: center;
          line-height: 12px;
          opacity: 0.8;
          margin: 6px;
        }
      }
    }
  }
}
</style>
